<div class="block-news">
<?
//xác định danh mục cha
$parname = array();
$parid = array();
foreach ($cat_pro as $parent){
    $parname[$parent['id']] = utf8_to_ascii($parent['name']);
    $parid[$parent['id']] = $parent['id'];
    $parseokey[$parent['id']] = utf8_to_ascii($parent['seo_key']);
}
//get list id cha
$get_array_cat_pro = getArray('xteam_category','parent_id='.$id);
if($get_array_cat_pro){
    foreach($get_array_cat_pro as $item_cat_pro){
        $list_id .= $item_cat_pro['id'].',';
    }
    $per_page = 18;
    $page_no = $p;
    $first = ($page_no) * $per_page;
    $limit = $first . ',' . $per_page;
    //set dieu kien loc dang sach id chuyen muc con
    $filter = 'status=1 AND parent_id IN ('.substr($list_id,0,-1).')';
    $list_product = getArray('xteam_product',$filter,$limit,'is_hot DESC,date_added DESC, sort ASC');
    $list_pro = getArray('xteam_product',$filter);
    if($list_pro) $total = count($list_pro);
    $num=0;
    if($list_product){
        foreach($list_product as $list_pro){
            $properties = product_properties($list_pro['id']);
            $num++;
            $class = $num%2!==0? 'block-left' : 'block-right';
            if($parid[$list_pro['parent_id']]%2==0){$class_sp="rental";}else{$class_sp="salse";}?>
            <div class="<?=$class?>">
                <h2 class="title-news">
                    <?=$list_pro['is_hot']==1?'<img src="'.$curHost.'images/hot.gif" alt="'.utf8_to_ascii($list_pro['name']).'" />':''?>
                    <a href="<?=$curHost.utf8_to_ascii($parseokey[$list_pro['parent_id']]!=''?$parseokey[$list_pro['parent_id']]:$parname[$list_pro['parent_id']]).'/'.utf8_to_ascii($parseokey[$list_pro['parent_id']]!=''?$parseokey[$list_pro['parent_id']]:$parname[$list_pro['parent_id']])?>/7/<?=$parid[$list_pro['parent_id']]?>.html">
                        <span class="<?=$class_sp?>"><?=$parname[$list_pro['parent_id']]?> | </span>
                    </a>
                    <a href="<?=$curHost.utf8_to_ascii($parseokey[$list_pro['parent_id']]!=''?$parseokey[$list_pro['parent_id']]:$parname[$list_pro['parent_id']])?>/<?=utf8_to_ascii($list_pro['seo_key']!=''?$list_pro['seo_key']:$list_pro['name'])?>/1/<?=$list_pro['id']?>.html" title="<?=$list_pro['name']?>">
                        <?=$list_pro['name']?>
                    </a>
                </h2>
                <? if($list_pro['image_thumbs']!=''){?>
                <a href="<?=$curHost.utf8_to_ascii($parseokey[$list_pro['parent_id']]!=''?$parseokey[$list_pro['parent_id']]:$parname[$list_pro['parent_id']])?>/<?=utf8_to_ascii($list_pro['seo_key']!=''?$list_pro['seo_key']:$list_pro['name'])?>/1/<?=$list_pro['id']?>.html" title="<?=$list_pro['name']?>">
                    <img src="<?=$curHost.$list_pro['image_thumbs']?>" alt="<?=$list_pro['seo_key'].'-'.$list_pro['name']?>" class="img-news" title="<?=$list_pro['name']?>" />
                </a>
                <? }else{?>
                <a href="<?=$curHost.utf8_to_ascii($parseokey[$list_pro['parent_id']]!=''?$parseokey[$list_pro['parent_id']]:$parname[$list_pro['parent_id']])?>/<?=utf8_to_ascii($list_pro['seo_key']!=''?$list_pro['seo_key']:$list_pro['name'])?>/1/<?=$list_pro['id']?>.html" title="<?=$list_pro['name']?>">
                    <img src="<?=$curHost?>images/no_image.gif" alt="<?=$list_pro['seo_key']." - ".$list_pro["name"]?>"  class="img-news" style="display: inline;" title="<?=$list_pro['name']?>" />
                </a>
                <? }?>
                <div class="short-news">
                    <ul>
                    <?
                    if($properties){
                        foreach($properties as $prop){?>
                        <li><label><?=$prop['cat']?>:&nbsp;</label><span><?=$prop['name']?></span></li>
                    <?
                        }
                    }else{?>
                        <li><label>đang cập nhật</label></li>
                    <? }?>
                    </ul>
                </div>
            </div>
        <?
            if($num%2==0 || $num >=count($list_product)){
                echo '<div class="clear"></div></div><div class="block-news">';
            }
        }
    }
    ?>
    </div>
    <script language="javascript" type="text/javascript">
        $(document).ready(function(){
            var contentdiv = $('.block-news').text(function(){
                if ($.trim($(this).text())==''){
                    $(this).hide();
                }
            });
        })
    </script>
    <?
    $rowPage = $_lang=="vn" ? "Sản phẩm" : "Products";
    $pagePage = $_lang=="vn" ? "Trang" : "Page";
    if($_lang=="vn"){
        $$rowPage       = "Sản phẩm";
        $pagePage       = "Trang";
        $titleFirst 	= "&laquo;";
        $titlePrevious 	= "&lsaquo;";
        $titleNext 	= "&rsaquo;";
        $titleLast 	= "&raquo;";
    }else if($_lang=="en"){
        $rowPage = "Products";
        $pagePage 	= "Page";
        $titleFirst 	= "First";
        $titlePrevious 	= "Previous";
        $titleNext 	= "Next";
        $titleLast 	= "Last";
    }else{
        $rowPage = "新聞";
        $pagePage 	= "頁";
        $titleFirst 	= "首先";
        $titlePrevious 	= "上一頁";
        $titleNext 	= "下一頁";
        $titleLast 	= "最後";
    }
    $pages_no = countPages($total,$per_page);
    if($total>$per_page || $page_no>0){
    ?>
    <div class="pagging">
        <ul class="page-numbers">
            <? if($p!='' && $p>1){?>
                <? //if(){?>
                <li><a title="<?=$titleFirst?>" id="first" href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_GET['ali'])?>/7/<?=$id?>/page-1.html"><?=$titleFirst?></a></li>
                <li><a title="<?=$titlePrevious?>" id="previous" href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_GET['ali'])?>/7/<?=$id?>/page-<? if($p-1<0){echo $p=1;}else{echo $p-1;}?>.html"><?=$titlePrevious?></a></li>
                <? //}?>
            <? }?>
            <? $from=($p-10>0?$p-10:0); $to=($p+10<$pages_no?$p+10:$pages_no);
            for ($i=$from;$i<$to;$i++){
                if ($i+1!=$p && $i+1>0) {?>
                    <li><a href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_GET['ali'])?>/7/<?=$id?>/page-<?=$i+1?>.html"><?=$i+1?></a></li>
            <? }else{?>
                    <li><a class="active"><?=($i+1)?></a></li>
            <? }
            }?>
            <? if($pages_no>0 && $p<$pages_no){?>
                <li><a title="<?=$titleNext?>" id="next" href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_GET['ali'])?>/7/<?=$id?>/page-<? if($p+1>$pages_no){echo $p=$pages_no;}else{if($p==''){echo $p+2;}else{echo $p+1;}}?>.html"><?=$titleNext?></a></li>
                <li><a title="<?=$titleLast?>" id="last" href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_GET['ali'])?>/7/<?=$id?>/page-<? if($p+1>$pages_no){echo $p=$pages_no;}else{echo $pages_no;}?>.html"><?=$titleLast?></a></li>
            <? }?>
        </ul>
    </div>
    <? }
}else{
    require_once 'modules/error.php';
}?>